#include "stdafx.h"
#include "App.h"
#include "AppWindow.h"

int APIENTRY _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd )
{
	VWD::App app;

#ifdef UNICODE
	if(wcscmp(lpCmdLine,L"config")==0)
#else
	if(strcmp(lpCmdLine,"config")==0)
#endif
		app.Config();
	else
	{
		VWD::AppWindow::getInstanceRef().SetHinstance((size_t)hInstance);
		VWD::AppWindow::getInstanceRef().SetCmdShow(nShowCmd);

		try 
		{
			app.Go();		
		} 
		catch(Ogre::Exception& e) 
		{
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
			MessageBoxA(NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
			fprintf(stderr, "An exception has occurred: %s\n",e.getFullDescription().c_str());
#endif
		}
	}

	return 0;	
}